package com.cz.controller.admin;

import com.cz.pojo.User;
import com.cz.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @author Kartoffel
 * @create 2020-09-26-18:25
 */
@Controller
public class Login {

    @Autowired
    private UserService userService;

    @GetMapping("/login")
    @ResponseBody
    public String login(String username, String password,Model model, HttpSession session){
        User user = userService.queryLogin(username);
        System.out.println(user);
        if(user.getPassword().equals(password)){
            return user.toString();
        }
        return null;
    }

}
